package com.example.base.security.handler;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.base.security.domain.SelfUserEntity;
import com.example.base.security.domain.SysUserEntity;
import com.example.base.security.domain.SysUserToken;
import com.example.base.security.jwt.JWTConfig;
import com.example.base.security.jwt.JWTTokenUtil;
import com.example.base.security.service.LoginService;
import com.example.base.security.service.SysUserTokenService;
import com.example.base.utils.ResponseUtils;
import io.jsonwebtoken.Claims;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/6/11 15:10
 * @since JDK 1.8
 */
@Slf4j
@Component
public class UserLoginSuccessHandler implements AuthenticationSuccessHandler {


    @Autowired
    private LoginService loginService;

    /**
     * 登录成功返回结果
     * @Author Sans
     * @CreateTime 2019/10/3 9:27
     */
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication){
        loginService.loginSuccess(response,authentication);
    }
}
